#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <sys/wait.h>
#include <signal.h>

int main()
{
	pid_t pid = fork();
	if(pid > 0)
	{
		// 父进程，回收子进程资源
		int s;
		pid_t wpit = wait(&s);
		printf("child died pid = %d\n", wpit);
		// printf("%d\n", s);
		if(WIFSIGNALED(s))
		{
			printf("died by signal: %d\n", WTERMSIG(s));
		}
	}
	else if(pid = 0)
	{
		raise(SIGKILL);
	}
	
	return 0; 
}
